package com.endava.FlowControlAndAssertions;

public class Ex6_3 {

	public static void main(String[] args) {
		day(14, 1, 2025);
	}

	public static void day(int days, int months, int years) {
		int m = 3;
		int y = 2013;

		int[] month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int[] month2 = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		String[] zz = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
				"Saturday", "Sunday" };

		if (years == y) {
			// merge
			if (months == m) {
				// 4 - vineri - al patrulea element in zz
				// days - nr de days a lunii
				// -1 pt a scadea data de 1...sa incepem de la 0
				// %7 pt ca sunt 7 elem in zz
				System.out.println(zz[(4 + days - 1) % 7]);
			}
			// merge
			else if (months > m) {
				int nr = 0;
				for (int i = m; i < months; i++) {
					nr += month[i - 1];
				}
				System.out.println(zz[(3 + nr + days) % 7]);
			} else {
				int nr = 0;
				for (int i = months - 1; i < m; i++) {
					nr += month[i];
				}
				System.out.println(zz[Math.abs(4 - nr + days) % 7]);
			}
		}

		else if (years > y) {
			// an bisect
			if (years % 4 == 0) {
				// merge
				if (months == m) {
					System.out
							.println(zz[(4 + days + ((years - y) / 4) * 366 + (years
									- y - (years - y) / 4) * 365) % 7]);
				}

				// merge
				else if (months > m) {
					int nr = 0;
					for (int i = m; i < months; i++) {
						nr += month2[i - 1];

					}
					System.out.println(zz[(4 + nr + days + ((years - y) / 4)
							* 366 + (years - y - (years - y) / 4) * 365) % 7]);
				}

				else {
					int nr = 0;
					for (int i = months - 1; i < m - 1; i++) {
						nr += month2[i];
					}
					// System.out.println(zz[Math.abs(4-nr+days)%7]);
					System.out
							.println(zz[(((years - y) / 4) * 366
									+ (years - y - (years - y) / 4) * 365 + (4 - nr + days)) % 7]);

				}
			} else {
				if (months == m) {

					System.out
							.println(zz[(3 + days + ((years - y) / 4) * 366 + (years
									- y - (years - y) / 4) * 365) % 7]);
				}

				// merge
				else if (months > m) {
					int nr = 0;
					for (int i = m; i < months; i++) {
						nr += month[i - 1];

					}
					System.out.println(zz[(3 + nr + days + ((years - y) / 4)
							* 366 + (years - y - (years - y) / 4) * 365) % 7]);
				}

				else {
					int nr = 0;
					for (int i = months - 1; i < m - 1; i++) {
						nr += month[i];
					}
					// System.out.println(zz[Math.abs(4-nr+days)%7]);
					System.out
							.println(zz[(((years - y) / 4) * 366
									+ (years - y - (years - y) / 4) * 365 + (3 - nr + days)) % 7]);

				}
			}
		}

		// System.out.println();

	}

}
